<?php
header('content-type:text/html;charset=utf-8');

$servername = "localhost";
$username = "root";
$password = "root";
$db = 'sy2002';

// 创建连接
$conn = new mysqli($servername, $username, $password, $db);
 
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 
// echo "连接成功";
// echo json_encode($conn);
// $conn->query("SET NAMES utf-8");
$sql = 'SELECT * FROM `indexSon3`';
$result = $conn->query($sql);

$arr = array();
// 输出数据
while($row = $result->fetch_assoc()) {
    array_push($arr, $row);
}
// $res = $conn->query($sql);
// $arr = array();
// $row = $res->fetch_assoc();
// while($row = $res->fetch_assoc()){
//     array_push($arr,$row);
// };
echo json_encode($arr);
?>